package org.beanspirit.data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.text.DecimalFormat;

public class LoanDetailVO implements Serializable {
  private static final long serialVersionUID = 2699587544214915930L;
  private BigDecimal principal;
  private BigDecimal interest;
  private BigDecimal installment;
  private BigDecimal remaining;
  private String principalStr;
  private String interestStr;
  private String installmentStr;
  private String remainingStr;

  public LoanDetailVO(BigDecimal principal, BigDecimal interest, BigDecimal installment,
      BigDecimal remaining) {
    setPrincipal(principal);
    setInterest(interest);
    setInstallment(installment);
    setRemaining(remaining);
  }

  public BigDecimal getInstallment() {
    return installment;
  }

  public String getInstallmentStr() {
    return installmentStr;
  }

  public BigDecimal getInterest() {
    return interest;
  }

  public String getInterestStr() {
    return interestStr;
  }

  public BigDecimal getPrincipal() {
    return principal;
  }

  public String getPrincipalStr() {
    return principalStr;
  }

  public BigDecimal getRemaining() {
    return remaining;
  }

  public String getRemainingStr() {
    return remainingStr;
  }

  public void setInstallment(BigDecimal installment) {
    this.installment = installment;
    DecimalFormat format = new DecimalFormat("###,##0.00");
    format.setGroupingUsed(true);
    String value = format.format(installment);
    setInstallmentStr(value);
  }

  protected void setInstallmentStr(String installmentStr) {
    this.installmentStr = installmentStr;
  }

  public void setInterest(BigDecimal interest) {
    this.interest = interest;
    DecimalFormat format = new DecimalFormat("###,##0.00");
    format.setGroupingUsed(true);
    String value = format.format(interest);
    setInterestStr(value);
  }

  protected void setInterestStr(String interestStr) {
    this.interestStr = interestStr;
  }

  public void setPrincipal(BigDecimal principal) {
    this.principal = principal;
    DecimalFormat format = new DecimalFormat("###,##0.00");
    format.setGroupingUsed(true);
    String value = format.format(principal);
    setPrincipalStr(value);
  }

  protected void setPrincipalStr(String principalStr) {
    this.principalStr = principalStr;
  }

  public void setRemaining(BigDecimal remaining) {
    this.remaining = remaining;
    DecimalFormat format = new DecimalFormat("###,##0.00");
    format.setGroupingUsed(true);
    String value = format.format(remaining);
    setRemainingStr(value);
  }

  protected void setRemainingStr(String remainingStr) {
    this.remainingStr = remainingStr;
  }
}
